{% extends "base.html" %}
{% block title %}{{ lang.menu_links.monitoring.smon.agent }}{% endblock %}
{% block h2 %}{{ lang.menu_links.monitoring.smon.agent }}{% endblock %}
{% block content %}
{% from 'include/input_macros.html' import input, select %}
<script src="/app/static/js/smon.js"></script>
<script src="/inc/jquery.timeago.js" type="text/javascript"></script>
<link href="{{ url_for('static', filename='css/servers.css') }}" rel="stylesheet"/>
<link href="{{ url_for('static', filename='css/smon.css') }}" rel="stylesheet"/>
<link href="{{ url_for('static', filename='css/ha.css') }}" rel="stylesheet">
{% if user_subscription['user_status'] == 0  %}
	{% include 'include/no_sub.html' %}
{% elif smon_status in ('failed', 'inactive', 'ERROR') %}
<div style="text-align: center;">
	<br />
	<h3>{{lang.smon_page.desc.smon_is_not_run}}</h3>
	<img src="{{ url_for('static', filename='images/no_servers.png')}}" alt="There is no server">
	<h4>{{lang.smon_page.desc.run_smon}} <a href="/app/users/services" title="Roxy-WI services" target="_blank">{{lang.words.here}}</a> {{lang.smon_page.desc.before_use}}</h4>
</div>
{% else %}
{% if g.user_params['role'] <= 2 %}
<div class="add-button add-button-big" title="{{lang.smon_page.desc.add_agent}}" onclick="addAgentDialog();">+ {{lang.smon_page.desc.add_agent}}</div>
{% endif %}
<div class="up-pannel" class="sortable">
    {% for agent in agents %}
    <div id="agent-{{agent.id}}" class="div-server-hapwi animated-background"></div>
    {% endfor %}
</div>
    <div id="add-agent-page" style="display: none;">
        <table class="overview" id="add-agent-page-overview"
               title="{{lang.words.create|title()}} {{lang.words.w_a}} {{lang.words.new2}} {{lang.words.agent}}"
               data-edit="{{lang.words.edit|title()}} {{lang.words.agent}}">
            {% include 'include/tr_validate_tips.html' %}
            <tr>
                <td class="padding20">
                    {{lang.words.server|title()}}
                    <span class="need-field">*</span>
                </td>
                <td>
                    <select name="new-agent-server-id" id="new-agent-server-id">
                        <option value="------" disabled selected>------</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="padding20" style="width: 50%">
                    {{lang.words.name|title()}}
                    <span class="need-field">*</span>
                </td>
                <td>
                    {{ input('new-agent-name', autofocus='autofocus') }}
                </td>
            </tr>
            <tr>
                <td class="padding20">{{lang.words.enable|title()}}</td>
                <td>
                    {{ checkbox('new-agent-enabled', checked='checked') }}
                </td>
            </tr>
            <tr>
                <td class="padding20" style="width: 50%">
                    {{lang.words.desc|title()}}
                </td>
                <td>
                    {{ input('new-agent-desc', autofocus='autofocus') }}
                </td>
            </tr>
        </table>
    </div>
    <div id="dialog-confirm" style="display: none;">
        <p><span class="ui-icon ui-icon-alert" style="float:left; margin:3px 12px 20px 0;"></span>{{lang.phrases.are_you_sure}}</p>
    </div>
{% endif %}
<script>
    {% for agent in agents %}
        getAgent('{{agent.id}}');
    {% endfor %}
</script>
{% endblock %}
